package qgs.zisu.javaconcurrency.javaconcurrency.chapter7_synchronized;

/**
 * @Author: 蔡翔
 * @Date: 2019/10/9 16:15
 * @Version 1.0
 */
public class SynchronizedTest {
    private final static Object LOCK = new Object();

    public static void main(String[] args) {
        Runnable runnable = ()->{
            synchronized (LOCK){
                try {
                    System.out.println(Thread.currentThread().getName());
                    Thread.sleep(2_000);
                }catch (Exception e){
                    e.printStackTrace();
                }

            }
        };

        Thread t1 = new Thread(runnable);
        Thread t2 = new Thread(runnable);
        Thread t3 = new Thread(runnable);

        t1.start();
        t2.start();
        t3.start();
    }
}
